package com.css.bjdt_report.explain.service;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.css.bjdt_report.explain.entity.RptCellExplain;
import com.css.bjdt_report.util.CommonUtil;

@Service
public class RptCellExplainService {
	@Autowired
	private Dao dao;

	public void deleteAllCellByExplainId(String explainId) {
		dao.clear(RptCellExplain.class, Cnd.where("EXPLAIN_ID", "=", explainId));
	}

	public boolean batchInsert(List<RptCellExplain> records) {
		if (records == null || records.size() == 0) {
			return false;
		}
		for (RptCellExplain rptCellExplain : records) {
			if (StringUtils.isBlank(rptCellExplain.getCellExplainId())) {
				rptCellExplain.setCellExplainId(CommonUtil.getUUID());
			}
			dao.insert(rptCellExplain);
		}
		return true;
	}

	public List<RptCellExplain> queryAllCellExplainByExplainId(String explainId) {
		return dao.query(RptCellExplain.class, Cnd.where("EXPLAIN_ID", "=", explainId));
	}
}
